package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.ResultCodeEnum;
import lombok.Getter;

/**
 * 自定义异常类型
 */
@Getter
public class LeaseException extends RuntimeException {

    Integer code;

    public LeaseException(Integer code, String msg) {
        super(msg);
        this.code = code;
    }

    public LeaseException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

    @Override
    public String toString() {
        return "自定义异常：code=" + code + ";msg=" + this.getMessage();
    }
}
